{% extends "page.html" %}

{% block script %}
{{ super() }}
<script type="text/javascript">
    document.addEventListener('DOMContentLoaded', function() {
        let button = document.getElementById('eye');
        button.addEventListener("click", function(e) {
            let npwd = document.getElementById("new_password_input");
            let cpwd = document.getElementById("new_password_confirmation_input");
            if (npwd.getAttribute("type") === "password") {
                npwd.setAttribute("type", "text");
                cpwd.setAttribute("type", "text");
                button.textContent = "🔑";
            } else {
                npwd.setAttribute("type", "password");
                cpwd.setAttribute("type", "password");
                button.textContent = "👁";
            }
        });
    });
</script>
{% endblock script %}

{% block main %}
<div class="container">
    <form action="{{post_url}}" method="post" role="form">
        <h1>
            Change password for {{user_name}}
        </h1>
        
        <p>Please enter the new password you want to set for {{user_name}}.</p>
        <input type="hidden" name="_xsrf" value="{{ xsrf }}"/>
        <div class="form-group">     
            <label for="new_password_input">New password:</label>
            <div class="input-group col-xs-6">
                <input id="new_password_input" type="password" name="new_password" val="" autocapitalize="off" autocorrect="off" class="form-control" />
                <span class="input-group-addon">
                    <button id="eye" type="button" style="border:0;">👁</button>
                </span>
            </div>
            <p></p>
            
            <label for="new_password_confirmation_input">Confirm new password:</label>
            <div class="input-group col-xs-6">
                <input id="new_password_confirmation_input" type="password" name="new_password_confirmation" val="" autocapitalize="off" autocorrect="off" class="form-control" />
            </div>
            <p></p>

            <input id="signup_submit" type="submit" value='Change Password' class='btn btn-jupyter' />
        </div>
    </form>

    {% if result_message %}
        <div class="alert {{alert}} col-xs-6" role="alert">{{result_message}}</div>
    {% endif %}
</div>
{% endblock %}
